Stabilize Spanner integration tests and capture failure logs - #275
Closed
fforootd wants to merge 1 commit into
Closed
Stabilize Spanner integration tests and capture failure logs#275fforootd wants to merge 1 commit into
fforootd wants to merge 1 commit into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
There was a problem hiding this comment.
Pull request overview
This PR aims to make the Go Spanner integration test matrix more stable and diagnosable by hardening integration-test harness initialization for concurrency, reducing schema-collision flakiness in flow definition tests, and preserving failure logs as CI artifacts.
Changes:
- Remove the Spanner-specific skip for JSON schema repository CRUD tests so Spanner coverage matches Postgres.
- Make integration-test harness lazy initialization concurrency-safe and adjust flow definition tests to use per-test schema IDs (and reduce intra-package parallelism).
- Capture
go test -jsonoutput for Spanner integration tests and upload it as a CI artifact on failure.
Reviewed changes
Copilot reviewed 22 out of 22 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| internal/storage/database/repository/json_schema_test.go | Removes Spanner-only skip to run JSON schema CRUD tests on Spanner. |
| internal/api/integration_test/helpers/user.go | Adds mutex-guarded lazy init for user service/repo. |
| internal/api/integration_test/helpers/user_password.go | Adds mutex-guarded lazy init for user password repo. |
| internal/api/integration_test/helpers/user_passkey.go | Adds mutex-guarded lazy init for user passkey repo. |
| internal/api/integration_test/helpers/team.go | Adds mutex-guarded lazy init for team repo/service. |
| internal/api/integration_test/helpers/spanner_database.go | Adds mutex-guarded lazy init for Spanner DB pool. |
| internal/api/integration_test/helpers/session.go | Adds mutex-guarded lazy init for session service/repo. |
| internal/api/integration_test/helpers/server.go | Adds mutex-guarded lazy init for generated server/test server/handlers. |
| internal/api/integration_test/helpers/secrets.go | Adds mutex-guarded lazy init for secret generator. |
| internal/api/integration_test/helpers/schema.go | Adds mutex-guarded lazy init for schema components; introduces “ensure schema exists” helpers and schema-ID helpers. |
| internal/api/integration_test/helpers/project.go | Adds mutex-guarded lazy init for project repo/service. |
| internal/api/integration_test/helpers/pg_database.go | Adds mutex-guarded lazy init for Postgres DB pool. |
| internal/api/integration_test/helpers/http_client.go | Adds mutex-guarded lazy init for shared HTTP client. |
| internal/api/integration_test/helpers/harness.go | Introduces mutexes on Harness for safe concurrent initialization. |
| internal/api/integration_test/helpers/flow.go | Adds mutex-guarded lazy init for flow service/state machine/repo. |
| internal/api/integration_test/helpers/flow_definition.go | Adds mutex-guarded lazy init for flow definition service. |
| internal/api/integration_test/helpers/crypto.go | Makes hasher/crypter initialization concurrency-safe and reuses a shared hasher instance. |
| internal/api/integration_test/helpers/client.go | Makes API client and security source maps concurrency-safe. |
| internal/api/integration_test/helpers/auth_attempt.go | Adds mutex-guarded lazy init for auth attempt service/repo. |
| internal/api/integration_test/flow_definition_test.go | Removes t.Parallel() usage and switches to per-test schema IDs to avoid collisions. |
| .github/workflows/ci.yml | Runs Spanner integration tests with -json output and uploads the log artifact on failure. |
| .changeset/spanner-test-stability.md | Adds an empty changeset for a non-release change. |
Comment on lines
12
to
+29
| func (h *Harness) EnsureTestServer(t *testing.T) *httptest.Server { | ||
| t.Helper() | ||
| h.mu.Lock() | ||
| server := h.TestServer | ||
| h.mu.Unlock() | ||
| if server != nil { | ||
| return server | ||
| } | ||
| server = httptest.NewServer( | ||
| h.EnsureGeneratedServer(t), | ||
| ) | ||
| h.mu.Lock() | ||
| if h.TestServer == nil { | ||
| h.TestServer = httptest.NewServer( | ||
| h.EnsureGeneratedServer(t), | ||
| ) | ||
| h.TestServer = server | ||
| } | ||
| return h.TestServer | ||
| server = h.TestServer | ||
| h.mu.Unlock() | ||
| return server |
Comment on lines
14
to
32
| func (h *Harness) EnsureDBPool(t *testing.T) database.Pool { | ||
| t.Helper() | ||
|
|
||
| h.mu.Lock() | ||
| pool := h.DBPool | ||
| h.mu.Unlock() | ||
| if pool != nil { | ||
| return pool | ||
| } | ||
| pool, err := Connector.Connect(t.Context()) | ||
| require.NoError(t, err) | ||
| h.mu.Lock() | ||
| if h.DBPool == nil { | ||
| var err error | ||
| h.DBPool, err = Connector.Connect(t.Context()) | ||
| require.NoError(t, err) | ||
| h.DBPool = pool | ||
| } | ||
| return h.DBPool | ||
| pool = h.DBPool | ||
| h.mu.Unlock() | ||
| return pool | ||
| } |
Comment on lines
14
to
32
| func (h *Harness) EnsureDBPool(t *testing.T) database.Pool { | ||
| t.Helper() | ||
|
|
||
| h.mu.Lock() | ||
| pool := h.DBPool | ||
| h.mu.Unlock() | ||
| if pool != nil { | ||
| return pool | ||
| } | ||
| pool, err := Connector.Connect(t.Context()) | ||
| require.NoError(t, err) | ||
| h.mu.Lock() | ||
| if h.DBPool == nil { | ||
| var err error | ||
| h.DBPool, err = Connector.Connect(t.Context()) | ||
| require.NoError(t, err) | ||
| h.DBPool = pool | ||
| } | ||
| return h.DBPool | ||
| pool = h.DBPool | ||
| h.mu.Unlock() | ||
| return pool | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Testing